package main

import (
	"errors"
	"gitee.com/enjoy_5/integral-rpc/internal/api"
	"gitee.com/enjoy_5/integral-rpc/internal/model"
	"gitee.com/xuxinzhi2206/corehub/grpc"
	"gitee.com/xuxinzhi2206/corehub/viper"
	grpc2 "google.golang.org/grpc"
)

func main() {
	err := viper.GetViper("./config.yaml")
	if err != nil {
		panic(errors.New("viper read failed"))
	}

	err = model.AutoMigrate()
	if err != nil {
		panic(errors.New("auto migrate failed"))
	}

	err = grpc.RegisterRPC(func(s *grpc2.Server) {
		api.Register(s)
	})
	if err != nil {
		panic(err.Error())
	}
}
